/*
   Copyright 2009 Abdulla Abdurakhmanov (abdulla@latestbit.com)
   Original sources are available at www.latestbit.com

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

package org.latestbit.smartobjects.network;

import java.io.IOException;

import org.latestbit.smartobjects.IDestroyable;
import org.latestbit.smartobjects.exceptions.IncorrectURIException;

/**
 * Interface describes methods for managed server
 * @author abdulla-a
 *
 */
public interface IManagedServer extends IDestroyable {
	/**
	 * Starts server and all acceptors
	 * @throws IncorrectURIException
	 * @throws IOException
	 */
	public abstract void start() throws IncorrectURIException, IOException;

	/**
	 * Stops server and all acceptors
	 */
	public abstract void stop();
	
	/**
	 * Sets network acceptors configuration/addresses
	 * @param location network location (addresses)
	 * @param coordinator network endpoint coordinator instance
	 * @throws IncorrectURIException
	 * @throws IOException
	 */
	public abstract void setEndpointLocation(IEndpointLocation location, IEndpointCoordinator coordinator) 
		throws IncorrectURIException, IOException;	

	/**
	 * Gets network acceptors configuration/addresses
	 * @return endpoint location
	 */
	public IEndpointLocation getEndpointLocation();
	
	/**
	 * Adds event listener
	 * @param listener event listener instance
	 */
	public void addListener(IManagedServerListener listener);
	
	/**
	 * Deletes event listener
	 * @param listener event listener instance
	 */
	public void delListener(IManagedServerListener listener);
}
